﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Data.SqlClient;
using System.Text;
using Castle.Services.Transaction;
using Meqs.Entity;
using Meqs.Entity.Views;
using Meqs.Logic.Interface;

namespace Meqs.Logic.Implement
{
    public class StudentEvalsLogic : CommonLogic<StudentEvals, int>, IStudentEvalsLogic
    {
        private readonly IGlobalCauseInfoLogic _cLogic;
        private readonly IGlobalTermInfoLogic _tLogic;
        private readonly IEvalSheetsLogic _esLogic;
        private readonly ISchoolInfoLogic _siLogic;

        public StudentEvalsLogic(IGlobalCauseInfoLogic _cLogic, IGlobalTermInfoLogic _tLogic, IEvalSheetsLogic _esLogic, ISchoolInfoLogic _siLogic)
        {
            this._cLogic = _cLogic;
            this._tLogic = _tLogic;
            this._esLogic = _esLogic;
            this._siLogic = _siLogic;
        }

        #region Implementation of ICommonLogic<StudentEvals, int>

        /// <sammury>
        /// 创建对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Create(StudentEvals entity)
        {
            return CreateObject(entity);
        }

        /// <sammury>
        /// 更新对象
        /// </sammury>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Update(StudentEvals entity)
        {
            return UpdateObject(entity);
        }

        /// <summary>
        /// 删除对象
        /// </summary>
        /// <param name="entityId"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int Delete(int entityId, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("RID", entityId);
            ht.Add("SchoolMark", schoolMark);
            return DeleteCustomer("StudentEvals.Delete", ht);
        }

        /// <summary>
        /// 删除所有对象
        /// </summary>
        /// <returns></returns>
        public int DeleteAll(string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            return DeleteCustomer("StudentEvals.Delete", ht);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="entityId"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public StudentEvals FindById(int entityId, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("RID", entityId);
            ht.Add("SchoolMark", schoolMark);
            return FindCustomerByID<StudentEvals>("StudentEvals.FindById", ht);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public int FindCount(string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            return FindCustomerByCount("StudentEvals.FindCount", ht);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public IList<StudentEvals> FindAll(string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            return FindCustomer<StudentEvals>("StudentEvals.Find", ht);
        }

        /// <summary>
        /// 检索对象数量
        /// </summary>
        /// <returns></returns>
        public int FindCount(Hashtable table)
        {
            return FindObjectByCount(table);
        }

        /// <sammury>
        /// 检索对象
        /// </sammury>
        public IList<StudentEvals> FindAll(Hashtable table)
        {
            return FindObject(table);
        }

        #endregion

        public ArrayList FindStudentEvalInfo(String schoolMark, int schoolYear, int id)
        {
            return FindStudentEvalInfo(schoolMark, schoolYear, id, 0);
        }
        public ArrayList FindStudentEvalInfo(String schoolMark, int schoolYear, int id, int evalType)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("SchoolMark", schoolMark);
                if (schoolYear != 0)
                    ht.Add("SchoolYear", schoolYear);
                if (id != 0)
                    ht.Add("RID", id);
                ht.Add("EvalType", evalType);
                ArrayList list = FindCustomer("StudentEvals.FindStudentEvalInfo", ht) as ArrayList;
                if (evalType == 1)
                    GetGradeList(schoolMark, list);
                else
                    GetCauseList(schoolMark, list);

                return list;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        private void GetCauseList(String schoolMark, ArrayList list)
        {
            IList<GlobalCauseInfo> causes = _cLogic.SelectSchoolCause(schoolMark);
            StringBuilder sb = null;
            foreach (StudentEvalInfo info in list)
            {
                if (String.IsNullOrEmpty(info.SubjectIdList))
                    continue;
                sb = new StringBuilder();
                String[] idArr = info.SubjectIdList.Split(new char[] { ',' });
                foreach (string s in idArr)
                {
                    foreach (GlobalCauseInfo cause in causes)
                    {
                        if (cause.RID.ToString() == s)
                        {
                            sb.Append(cause.CauseName);
                            sb.Append(",");
                            break;
                        }
                    }
                }
                info.SubjectNameList = sb.ToString();
                info.SubjectNameList = info.SubjectNameList.Substring(0, info.SubjectNameList.Length - 1);
            }
        }

        private void GetGradeList(String schoolMark, ArrayList list)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            IList<SchoolInfo> schoolList = _siLogic.FindAll(ht);
            Hashtable classList = new Hashtable();
            switch (schoolList[0].SchoolOpt)
            {
                case 1:
                    classList.Add("一年级", "1");
                    classList.Add("二年级", "2");
                    classList.Add("三年级", "3");
                    classList.Add("四年级", "4");
                    classList.Add("五年级", "5");
                    classList.Add("六年级", "6");
                    break;
                case 2:
                    classList.Add("初一", "7");
                    classList.Add("初二", "8");
                    classList.Add("初三", "9");
                    break;
                case 3:
                    classList.Add("高一", "10");
                    classList.Add("高二", "11");
                    classList.Add("高三", "12");
                    break;
                case 4:
                    classList.Add("一年级", "1");
                    classList.Add("二年级", "2");
                    classList.Add("三年级", "3");
                    classList.Add("四年级", "4");
                    classList.Add("五年级", "5");
                    classList.Add("六年级", "6");
                    classList.Add("初一", "7");
                    classList.Add("初二", "8");
                    classList.Add("初三", "9");
                    break;
                case 5:
                    classList.Add("初一", "7");
                    classList.Add("初二", "8");
                    classList.Add("初三", "9");
                    classList.Add("高一", "10");
                    classList.Add("高二", "11");
                    classList.Add("高三", "12");
                    break;
            }

            StringBuilder sb = null;
            foreach (StudentEvalInfo info in list)
            {
                int studentCount = 0;
                int evaledCount = 0;
                //info.Progress = "";
                try
                {
                    if (!String.IsNullOrEmpty(info.SubjectIdList))
                    {
                        if (info.SubjectIdList[info.SubjectIdList.Length - 1] == ',')
                        {
                            info.SubjectIdList = info.SubjectIdList.Substring(0, info.SubjectIdList.Length - 1);
                        }
                        ht = new Hashtable();
                        ht.Add("SchoolMark", schoolMark);
                        ht.Add("GradeList", info.SubjectIdList);
                        IList<int> studentCountList = FindCustomer<int>("StudentEvals.FindGradeStudentCount", ht) as IList<int>;
                        if (studentCountList != null && studentCountList.Count > 0)
                            studentCount = (int)studentCountList[0];
                    }
                }
                catch (Exception e)
                {
                    studentCount = 0;
                }
                try
                {
                    ht = new Hashtable();
                    ht.Add("SchoolMark", schoolMark);
                    ht.Add("SEID", info.Rid);
                    IList<int> evaledCountList = FindCustomer<int>("StudentEvals.FindEvaledStudentCount", ht) as IList<int>;
                    if (evaledCountList != null && evaledCountList.Count > 0)
                        evaledCount = (int)evaledCountList[0];
                }
                catch (Exception e)
                {
                    evaledCount = 0;
                }
                info.Progress = String.Format("{0}/{1}", evaledCount, studentCount);

                if (String.IsNullOrEmpty(info.SubjectIdList))
                    continue;
                sb = new StringBuilder();
                String[] idArr = info.SubjectIdList.Split(new char[] { ',' });
                foreach (string s in idArr)
                {
                    foreach (DictionaryEntry entry in classList)
                    {
                        if (entry.Value.ToString() == s)
                        {
                            sb.Append(entry.Key.ToString());
                            sb.Append(",");
                            break;
                        }
                    }
                }
                info.SubjectNameList = sb.ToString();
                info.SubjectNameList = info.SubjectNameList.Substring(0, info.SubjectNameList.Length - 1);
            }
        }

        /// <summary>
        /// 添加评估活动
        /// </summary>
        public int CreateEval(StudentEvals template, String schoolMark)
        {
            try
            {
                IList<GlobalTermInfo> terms = _tLogic.FindAll();
                if (terms.Count > 0)
                {
                    template.SchoolYear = terms[0].GlobalYear;
                    template.Term = terms[0].GlobalTerm;
                }
                else
                {
                    template.SchoolYear = 0;
                    template.Term = 0;
                }
                Hashtable ht = new Hashtable();
                ht.Add("StudentEvals", template);
                ht.Add("SchoolMark", schoolMark);

                int id = (int)InsertCustomer("StudentEvals.CreateEval", ht);
                return id;
            }
            catch (Exception e)
            {
                return -1;
            }
        }

        /// <summary>
        /// 更新评估活动
        /// </summary>
        public int UpdateEval(StudentEvals template, String schoolMark)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("StudentEvals", template);
                ht.Add("SchoolMark", schoolMark);

                int id = (int)UpdateCustomer("StudentEvals.UpdateEval", ht);
                return id;
            }
            catch (Exception e)
            {
                return -1;
            }
        }

        /// <summary>
        /// 获取有评价的学年
        /// </summary>
        public ArrayList FindSchoolYears(String schoolMark)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("SchoolMark", schoolMark);
                ArrayList list = FindCustomer("StudentEvals.FindSchoolYears", ht) as ArrayList;
                return list;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        /// <summary>
        /// 获取有评价的学年
        /// </summary>
        public ArrayList FindSchoolYears(String schoolMark, int evalType)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("SchoolMark", schoolMark);
                ht.Add("EvalType", evalType);
                ArrayList list = FindCustomer("StudentEvals.FindSchoolYears", ht) as ArrayList;
                return list;
            }
            catch (Exception e)
            {
                return null;
            }
        }

        /// <summary>
        /// 删除学生评价
        /// </summary>
        [Transaction(TransactionMode.RequiresNew)]
        public int DeleteEval(int id, String schoolMark)
        {
            ArrayList esList = _esLogic.GetStudentEvals(id, schoolMark);
            if (esList != null)
            {
                foreach (EvalSheets sheets in esList)
                {
                    if (sheets.SeID != 0)
                    {
                        _esLogic.DeleteEvalSheetByStudentEval(sheets.SeID, schoolMark);
                    }
                }
            }

            return this.Delete(id, schoolMark);
        }

        /// <summary>
        /// 打开一个学生评价
        /// </summary>
        public int OpenEval(int id, String schoolMark, IList<int> causeList, int templateId)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("Rid", id);
                ht.Add("SchoolMark", schoolMark);
                ht.Add("State", 1);

                int ret = (int)UpdateCustomer("StudentEvals.OpenEval", ht);

                //EvalSheets es = new EvalSheets();
                //_esLogic.CreateStudentEval(es, schoolMark);

                return ret;
            }
            catch (Exception e)
            {
                return -1;
            }
        }

        /// <summary>
        /// 关闭一个学生评价
        /// </summary>
        public int CloseEval(int id, String schoolMark)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("Rid", id);
                ht.Add("SchoolMark", schoolMark);
                ht.Add("State", 2);

                int ret = (int)UpdateCustomer("StudentEvals.CloseEval", ht);
                return ret;
            }
            catch (Exception e)
            {
                return -1;
            }
        }

        /// <summary>
        /// 根据登陆的学生ID，获取当前的评价活动
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public StudentEvals FindeCurrentStudentEval(int studentID, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            StudentEvals eval = FindCustomerByID<StudentEvals>("StudentEvals.FindCurrentStudentEval", ht);
            if (eval == null || eval.CauseIDList == null) return null;
            string[] idList = eval.CauseIDList.Split(',');
            IList<int> targetCauseList = FindCustomer<int>("StudentEvals.FindStudentCauseList", studentID);
            IList<int> sourceCauseList = new List<int>();
            foreach (string s in idList)
            {
                if (s == "") continue;
                int causeID = int.Parse(s);
                if (targetCauseList.Contains(causeID))
                {
                    sourceCauseList.Add(causeID);
                }

            }
            return sourceCauseList.Count > 0 ? eval : null;
        }

        /// <summary>
        /// 根据制定的学生评教活动ID及学生ID，查询学生评价的教师
        /// </summary>
        /// <param name="currentStudentEval"></param>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public IList<TeacherInfoExtendCauseInfo> FindStudentEvalsTeacherList(StudentEvals currentStudentEval, int studentID, string schoolMark)
        {
            if (currentStudentEval == null) return new List<TeacherInfoExtendCauseInfo>();
            Hashtable ht = new Hashtable();
            ht.Add("CauseIDList", currentStudentEval.CauseIDList);
            ht.Add("StudentID", studentID);
            ht.Add("SchoolMark", schoolMark);
            IList<TeacherInfoExtendCauseInfo> list = FindCustomer<TeacherInfoExtendCauseInfo>("StudentEvals.FindStudentEvalsTeacherList", ht);
            IList<TeacherInfoExtendCauseInfo> resList = new List<TeacherInfoExtendCauseInfo>();
            foreach (TeacherInfoExtendCauseInfo info in list)
            {
                if (resList.Contains(info))
                {
                    int index = resList.IndexOf(info);
                    TeacherInfoExtendCauseInfo temp = resList[index];
                    resList.RemoveAt(index);
                    temp.CauseName += info.CauseName + ",";
                    resList.Add(temp);
                }
                else
                {
                    resList.Add(info);
                }
            }

            return resList;
        }

        /// <summary>
        /// 查询教师是否已经被评
        /// </summary>
        /// <param name="currentStudentEval"></param>
        /// <param name="teacherID"></param>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public bool TeacherPartObjState(StudentEvals currentStudentEval, int teacherID, int studentID, string schoolMark)
        {
            if (currentStudentEval == null) return false;
            Hashtable ht = new Hashtable();
            ht.Add("TeacherID", teacherID);
            ht.Add("StudentID", studentID);
            ht.Add("SchoolMark", schoolMark);
            ht.Add("EsID", currentStudentEval.RID);

            int count = FindCustomerByID<int>("StudentEvals.TeacherPartObjState", ht);
            return count > 0;
        }

        /// <summary>
        /// 查询SheetItems
        /// </summary>
        /// <param name="currentStudentEval"></param>
        /// <param name="teacherID"></param>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public SheetItems FindTeacherSheetItems(StudentEvals currentStudentEval, int teacherID, int studentID, string schoolMark)
        {
            try
            {

                if (currentStudentEval == null) return null;
                Hashtable ht = new Hashtable();
                ht.Add("TeacherID", teacherID);
                ht.Add("SchoolMark", schoolMark);
                ht.Add("StudentEvalsID", currentStudentEval.RID);
                EvalSheets sheets = FindCustomerByID<EvalSheets>("EvalSheets.GetEvalSheetsByStudentEvals", ht);
                if (sheets == null) return null;

                ht.Clear();
                ht.Add("TeacherID", teacherID);
                ht.Add("StudentID", studentID);
                ht.Add("SchoolMark", schoolMark);
                ht.Add("EsID", sheets.RID);

                return FindCustomerByID<SheetItemsExtend>("SheetItems.FindTeacherSheetItems", ht);
            }
            catch (Exception)
            {
                return null;
            }
        }

        /// <summary>
        /// 查询SheetItems
        /// </summary>
        /// <param name="seID"></param>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public QualitySheetItems FindStudentEvalSheetItems(int seID, int studentID, string schoolMark)
        {
            try
            {
                Hashtable ht = new Hashtable();
                ht.Add("SeID", seID);
                ht.Add("StudentID", studentID);
                ht.Add("SchoolMark", schoolMark);
                return FindCustomerByID<QualitySheetItems>("QualitySheetItems.FindStudentEvalQualitySheetItems", ht);
            }
            catch (Exception)
            {
                return null;
            }
        }

        /// <summary>
        /// 判断该学生是否已经评完
        /// </summary>
        /// <param name="currentStudentEval"></param>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public bool CheckAllTeacherState(StudentEvals currentStudentEval, int studentID, string schoolMark)
        {
            try
            {
                if (currentStudentEval == null) return true;
                Hashtable ht = new Hashtable();
                ht.Add("CauseIDList", currentStudentEval.CauseIDList);
                ht.Add("StudentID", studentID);
                ht.Add("SchoolMark", schoolMark);
                IList<TeacherInfoExtendCauseInfo> list = FindCustomer<TeacherInfoExtendCauseInfo>("StudentEvals.FindStudentEvalsTeacherList", ht);
                IList<int> sourceList = new List<int>();
                foreach (TeacherInfoExtendCauseInfo info in list)
                {
                    if (!sourceList.Contains(info.RID))
                        sourceList.Add(info.RID);
                }
                ht.Clear();
                ht.Add("StudentID", studentID);
                ht.Add("StudentEvalID", currentStudentEval.RID);
                ht.Add("SchoolMark", schoolMark);
                IList<int> targetList = FindCustomer<int>("StudentEvals.CheckAllTeacherState", ht);

                // 判断两个数组是否相等Equals???

                int[] array1 = new int[sourceList.Count];
                sourceList.CopyTo(array1, 0);
                int[] array2 = new int[targetList.Count];
                targetList.CopyTo(array2, 0);
                return IsEquals(array1, array2);
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        /// <summary>
        /// 判断该学生是否已经评完
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public bool CheckAllTeacherState(int studentID, string schoolMark)
        {
            IList<StudentEvals> studentEvalsList = GetStudentEvalByStudent(studentID, schoolMark);
            foreach (StudentEvals eval in studentEvalsList)
            {
                bool state = CheckAllTeacherState(eval, studentID, schoolMark);
                if (!state) return false;
            }
            return true;
        }

        /// <summary> 
        /// 比较两个值型一维数组变量是否值相等 
        /// </summary> 
        /// <param name="array1">值型一维数组1</param> 
        /// <param name="array2">值型一维数组2</param> 
        /// <returns>比较结果，相等则true，否则false</returns> 
        private static bool IsEquals(Array array1, Array array2)
        {
            //比较类型是否一样 
            if (!Object.ReferenceEquals(array1.GetType(), array2.GetType()))
            {
                return false;
            }

            //比较长度是否一样 
            if (array1.GetLength(0) != array2.GetLength(0))
            {
                return false;
            }
            //比较成员是否对应相等 
            ValueType v1, v2;
            for (int i = 0; i < array1.GetLength(0); i++)
            {
                v1 = (ValueType)array1.GetValue(i);
                v2 = (ValueType)array2.GetValue(i);
                if (!v1.Equals(v2))
                {
                    return false;
                }
            }
            return true;
        }

        /// <summary>
        /// 更新指定学生评教活动的脏数据
        /// </summary>
        public bool UpdateDirtyData(int seId, String schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("SEID", seId);
            IList<EvalSheets> esList = _esLogic.FindAll(ht);
            foreach (EvalSheets sheets in esList)
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();
                    SqlCommand cmd = conn.CreateCommand();

                    cmd.CommandText = "PROC_CALCULATE_DIRTY_DATA";
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlParameter startDatePara = new SqlParameter("p_evalSheetId", SqlDbType.Int);
                    startDatePara.Value = sheets.RID;
                    cmd.Parameters.Add(startDatePara);

                    SqlParameter schoolMarkParam = new SqlParameter("p_schoolMark", SqlDbType.NVarChar);
                    schoolMarkParam.Value = schoolMark;
                    cmd.Parameters.Add(schoolMarkParam);

                    conn.Dispose();
                }
            }
            return true;
        }

        public IList<StudentEvalState> GetStudentEvalState(int seId, String schoolMark, String causeList)
        {
            Hashtable ht = new Hashtable();
            ht.Add("CauseIDList", causeList);
            ht.Add("SchoolMark", schoolMark);
            ht.Add("SEID", seId);
            return FindCustomer<StudentEvalState>("StudentEvals.GetStudentEvalState", ht);
        }
        /// <summary>
        /// 获取学生评教
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public IList<StudentEvals> GetStudentEvalByStudent(int studentID, string schoolMark)
        {
            return GetStudentEvalByStudent(studentID, EvalType.Teacher, schoolMark);
        }


        /// <summary>
        /// 获取学生评教
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="evalType"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public IList<StudentEvals> GetStudentEvalByStudent(int studentID, EvalType evalType, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("StudentID", studentID);
            ht.Add("SchoolMark", schoolMark);
            IList<int> list = FindCustomer<int>("StudentEvals.GetStudentCauseList", ht);
            if (list == null || list.Count == 0) return null;
            ht.Clear();
            string condition = " evaltype = " + (int)evalType + " and (1=1 ";
            foreach (int id in list)
            {
                condition += string.Format(" or ',' + CauseIDList + ',' like '%,{0},%'", id);
            }
            condition += ")";
            ht.Add("Condition", condition);
            ht.Add("SchoolMark", schoolMark);

            IList<StudentEvals> seList = FindCustomer<StudentEvals>("StudentEvals.GetStudentEvalByStudent", ht);
            ListSort<StudentEvals> ls = new ListSort<StudentEvals>(seList, "StartDate", false);
            seList = ls.Sort();
            IList<StudentEvals> resList = new List<StudentEvals>();
            foreach (StudentEvals eval in seList)
            {
                IList<TeacherInfoExtendCauseInfo> teachers = FindStudentEvalsTeacherList(eval, studentID, schoolMark);
                if (teachers != null && teachers.Count > 0) resList.Add(eval);
            }

            return resList;
        }

        /// <summary>
        /// 获取学生评教
        /// </summary>
        /// <param name="studentID"></param>
        /// <param name="schoolMark"></param>
        /// <returns></returns>
        public IList<StudentEvals> GetStudentEvalByStudentID(int studentID, string schoolMark)
        {
            Hashtable ht = new Hashtable();
            ht.Add("StudentID", studentID);
            ht.Add("SchoolMark", schoolMark);
            return FindCustomer<StudentEvals>("StudentEvals.GetStudentEvalByStudentID", ht);
        }

        public IList<StudentEvals> GetQualityEvals(String schoolMark, DateTime begin, DateTime end)
        {
            Hashtable ht = new Hashtable();
            ht.Add("SchoolMark", schoolMark);
            ht.Add("begin", begin);
            ht.Add("end", end);
            return FindCustomer<StudentEvals>("StudentEvals.GetQualityEvals", ht);
        }
    }
}
